package wickethub.web.page;

import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.RequiredTextField;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.validation.validator.UrlValidator;

import wickethub.domain.BlogPost;

public class EditBlogPostPanel extends Panel {
	
	public EditBlogPostPanel(String id, IModel<BlogPost> model) {
		super(id);
		
		setDefaultModel(model.getObject() instanceof BlogPost ? model : new Model<BlogPost>(new BlogPost()));
		
    	final Form<BlogPost> form = new Form<BlogPost>("form", new CompoundPropertyModel<BlogPost>(getDefaultModel()));
		
    	RequiredTextField<String> url = new RequiredTextField<String>("url");
    	url.add(new UrlValidator());
		form.add(url);
		
		add(form);
        
    }
    
}